# Project:	Mr Cloud
# Author:	gong_libin
# Date:		2013_05_09

CC ?= g++
CFLAGS ?= -g -Wall -fPIC

MR_GLIB ?= /usr/lib

MR_ENV ?= $(shell pwd)/../..
MR_LIB ?= $(MR_ENV)/lib

OBJECTS = *.o

MRGLOBAL = libmrglobal
MRGLOBAL_A = $(MRGLOBAL).a
MRGLOBAL_SO = $(MRGLOBAL).so
MRGLOBAL_SO_VER = $(MRGLOBAL_SO).0.0.1

TARGETS =				\
	$(MRGLOBAL_A)			\
	$(MRGLOBAL_SO_VER)

all: $(TARGETS) install

$(MRGLOBAL_A): $(OBJECTS)
	ar cru $(MRGLOBAL_A) $(OBJECTS)
	ranlib $(MRGLOBAL_A)

$(MRGLOBAL_SO_VER): $(OBJECTS)
	$(CC) $(CFLAGS) -shared -Wl,-soname,$(MRGLOBAL_SO) -o $(MRGLOBAL_SO_VER) $(OBJECTS)
	cp $(MRGLOBAL).* $(MR_LIB)/.

install:
	cp $(MRGLOBAL).* $(MR_GLIB)/.
	ln -s $(MR_GLIB)/$(MRGLOBAL_SO_VER) $(MR_GLIB)/$(MRGLOBAL_SO)

clean:
	rm -rf $(MR_GLIB)/$(MRGLOBAL).*
	rm -rf $(MRGLOBAL_SO_VER)
	rm -rf $(MRGLOBAL_A)
	rm -rf $(OBJECTS)
